<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org">
<div th:fragment="hope" class="hope">

    欢迎您：<strong th:text="${WorkContext.nickName}">cqnews</strong>
    <span>|</span>
    今天是：<span id="show">1970-01-01 00:00:00</span>

    <script type="text/javascript">
        window.onload = function() {
            var show = document.getElementById("show");
            setInterval(function() {
                var time = new Date();
                // 程序计时的月从0开始取值后+1
                var m = (time.getMonth() + 1)<10?("0"+(time.getMonth() + 1)):(time.getMonth() + 1);
                var d = (time.getDate() + 1)<10?("0"+(time.getDate())):(time.getDate());
                var h = (time.getHours() + 1)<10?("0"+(time.getHours())):(time.getHours());
                var mi = (time.getMinutes() + 1)<10?("0"+(time.getMinutes())):(time.getMinutes());
                var s = (time.getSeconds() + 1)<10?("0"+(time.getSeconds())):(time.getSeconds());
                var t = time.getFullYear() + "-" + m + "-" + d + " "
                    + h + ":" + mi + ":" + s;
                show.innerHTML = t;
            }, 1000);
        };
    </script>
</div>